<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Template Units For Numerical Applications</title>
<link href="TUNAstyles.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<style type="text/css">

.cabeza_cell {
  border-left: 1px solid #000000;
  border-right: 1px solid #000000;
  border-bottom: 1px solid #000000;
  border-top: 1px solid #000000;
  font-family: Arial,Helvetica,sans-serif;
  font-size: 11pt;
  background-color: #ffffff;
  font-weight: lighter;
  color: #000000;
  text-decoration: none;
}
</style>

</head><body>
<div>
<table align="center" width="640" border="0" cellspacing="2" cellpadding="5" class="border">
<tr>
 <td class="cabeza_cell"> 

  <font style="font-family: helvetica; color: #000000;" size=4>
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>TUNA</font> :
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>T</font>emplate
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>U</font>nits for
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>N</font>umerical 
    <font style="font-family: helvetica; color: #336699; font-weight=bold" size=5>A</font>pplications
 </font><br>
  
</td>
</tr>

<tr>
<td class="cabeza_cell">
 <span style="font-family: helvetica; color: #336699;">
 Documentation Ver 1.0.0 August 2011 by
 <a href="http://mmc.geofisica.unam.mx/luiggi">Luis M. de la Cruz</a> <br>
 <a href="http://mmc.geofisica.unam.mx"> GMMC </a> -
 <a href="http://www.geofisica.unam.mx/recnat/"> Depto. de Recursos Naturales </a> -
 <a href="http://www.geofisica.unam.mx"> Instituto de Geof&iacute;sica </a> -
 <a href="http://www.unam.mx"> UNAM </a><br>
 </span>
 </td>

</tr>

</table>
</div>
<br>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">Tuna/include/Meshes/GeneralMesh.hpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment"> *  Copyright (C) 2011  Luis M. de la Cruz Salas</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> *  This file is part of TUNA</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> *  TUNA is free software: you can redistribute it and/or modify</span>
<a name="l00007"></a>00007 <span class="comment"> *  it under the terms of the GNU General Public License as published by</span>
<a name="l00008"></a>00008 <span class="comment"> *  the Free Software Foundation, either version 3 of the License, or</span>
<a name="l00009"></a>00009 <span class="comment"> *  (at your option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> *  TUNA is distributed in the hope that it will be useful,</span>
<a name="l00012"></a>00012 <span class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00013"></a>00013 <span class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00014"></a>00014 <span class="comment"> *  GNU General Public License for more details.</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> *  You should have received a copy of the GNU General Public License</span>
<a name="l00017"></a>00017 <span class="comment"> *  along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00018"></a>00018 <span class="comment"> ------------------------------------------------------------------------*/</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifndef _GENERALMESH_H_</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _GENERALMESH_H_</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="Tuna_8hpp.html" title="Types and structures to be used inside of TUNA.">Tuna.hpp</a>&quot;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="keyword">namespace </span>Tuna {
<a name="l00027"></a>00027 
<a name="l00039"></a>00039 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Tmesh&gt;
<a name="l00040"></a><a class="code" href="classTuna_1_1GeneralMesh.html">00040</a> <span class="keyword">class </span><a class="code" href="classTuna_1_1GeneralMesh.html" title="General class for meshes.">GeneralMesh</a> {
<a name="l00041"></a>00041     
<a name="l00042"></a>00042 <span class="keyword">public</span>:
<a name="l00044"></a><a class="code" href="classTuna_1_1GeneralMesh.html#aa7036b4f255ec46446443d26b6a770c2">00044</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> Typeinfo&lt;Tmesh&gt;::prec_t <a class="code" href="classTuna_1_1GeneralMesh.html#aa7036b4f255ec46446443d26b6a770c2" title="Precision used for the numerical operations.">prec_t</a>;     
<a name="l00046"></a><a class="code" href="classTuna_1_1GeneralMesh.html#a69519790ee3b38108b997cf46aa264e8">00046</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structTuna_1_1TunaArray.html" title="tiny used mainly for extents and deltas of meshes (blitz-TinyVector based) and huge used for general ...">TunaArray&lt;prec_t,1&gt;::huge</a> <a class="code" href="classTuna_1_1GeneralMesh.html#a69519790ee3b38108b997cf46aa264e8" title="Arrays for numbers.">ScalarField1D</a>;
<a name="l00047"></a>00047 
<a name="l00048"></a>00048   <a class="code" href="classTuna_1_1GeneralMesh.html" title="General class for meshes.">GeneralMesh</a>() { 
<a name="l00049"></a>00049     <a class="code" href="classTuna_1_1GeneralMesh.html#adb1220f6fe8395185eba4973fa2e71e2" title="Dimension of the mesh.">Dim</a> = Typeinfo&lt;Tmesh&gt;::Dim; 
<a name="l00050"></a>00050     <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0].resize(1); 
<a name="l00051"></a>00051     <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[1].resize(1); 
<a name="l00052"></a>00052     <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[2].resize(1); 
<a name="l00053"></a>00053   }
<a name="l00054"></a>00054   ~<a class="code" href="classTuna_1_1GeneralMesh.html" title="General class for meshes.">GeneralMesh</a>() { }
<a name="l00055"></a>00055 
<a name="l00060"></a><a class="code" href="classTuna_1_1GeneralMesh.html#ac592a9acf8b29460a8dcf39fd50931a3">00060</a>   Tmesh&amp; <a class="code" href="classTuna_1_1GeneralMesh.html#ac592a9acf8b29460a8dcf39fd50931a3" title="This funtion gets an returns a reference to the derived class, using the Curiously Recursive Template...">asDerived</a>() { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>Tmesh&amp;<span class="keyword">&gt;</span>(*this); }    
<a name="l00061"></a>00061 
<a name="l00065"></a><a class="code" href="classTuna_1_1GeneralMesh.html#a4d38fa591e526444d6b50000d3eb7375">00065</a>   <span class="keywordtype">bool</span> <a class="code" href="classTuna_1_1GeneralMesh.html#a4d38fa591e526444d6b50000d3eb7375" title="Delegate responsabilities to derived classes.">calcPoints</a>()   { <span class="keywordflow">return</span> <a class="code" href="classTuna_1_1GeneralMesh.html#ac592a9acf8b29460a8dcf39fd50931a3" title="This funtion gets an returns a reference to the derived class, using the Curiously Recursive Template...">asDerived</a>().calcPoints(); }  
<a name="l00066"></a>00066 
<a name="l00070"></a><a class="code" href="classTuna_1_1GeneralMesh.html#aa4107c79e49fbc9c67fb1343d9cc62b8">00070</a>   <span class="keywordtype">bool</span> <a class="code" href="classTuna_1_1GeneralMesh.html#aa4107c79e49fbc9c67fb1343d9cc62b8" title="Delegate responsabilities to derived classes.">calcElements</a>() { <span class="keywordflow">return</span> <a class="code" href="classTuna_1_1GeneralMesh.html#ac592a9acf8b29460a8dcf39fd50931a3" title="This funtion gets an returns a reference to the derived class, using the Curiously Recursive Template...">asDerived</a>().calcElements(); }  
<a name="l00076"></a><a class="code" href="classTuna_1_1GeneralMesh.html#ad819ba5886fcdb4137b2c71948550bf1">00076</a>   <a class="code" href="classTuna_1_1GeneralMesh.html#a69519790ee3b38108b997cf46aa264e8" title="Arrays for numbers.">ScalarField1D</a> <a class="code" href="classTuna_1_1GeneralMesh.html#ad819ba5886fcdb4137b2c71948550bf1" title="Returns a std::vector&lt;prec_t&gt; with the coordinates distribution in the axis defined by the parameter ...">getCoord</a>(Axis_t a) 
<a name="l00077"></a>00077   {
<a name="l00078"></a>00078     <a class="code" href="classTuna_1_1GeneralMesh.html#a69519790ee3b38108b997cf46aa264e8" title="Arrays for numbers.">ScalarField1D</a> aux( <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[a].size() );
<a name="l00079"></a>00079     <span class="keywordtype">int</span> i = 0;
<a name="l00080"></a>00080     <span class="keywordflow">for</span>(viter = <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[a].begin(); viter != <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[a].end(); ++viter, ++i)
<a name="l00081"></a>00081       aux(i) = *viter;
<a name="l00082"></a>00082     <span class="keywordflow">return</span> aux;
<a name="l00083"></a>00083   }
<a name="l00084"></a>00084 
<a name="l00085"></a>00085   <span class="keyword">inline</span> vector&lt;double&gt; getX() { <span class="keywordflow">return</span> <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0]; }
<a name="l00086"></a>00086   <span class="keyword">inline</span> vector&lt;double&gt; getY() { <span class="keywordflow">return</span> <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[1]; }
<a name="l00087"></a>00087   <span class="keyword">inline</span> vector&lt;double&gt; getZ() { <span class="keywordflow">return</span> <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[2]; }
<a name="l00088"></a>00088   
<a name="l00095"></a><a class="code" href="classTuna_1_1GeneralMesh.html#ab75ef83d7d410c8b7360d12477876099">00095</a>   <span class="keywordtype">void</span> <a class="code" href="classTuna_1_1GeneralMesh.html#ab75ef83d7d410c8b7360d12477876099" title="Write the coordinates of the mesh to a file.">writeToFile</a>(<span class="keywordtype">string</span> filename) {
<a name="l00096"></a>00096     std::ofstream file (filename.c_str());
<a name="l00097"></a>00097     <span class="keywordflow">if</span> (!file) 
<a name="l00098"></a>00098       std::cout &lt;&lt; <span class="stringliteral">&quot;\n +-----+&quot;</span>
<a name="l00099"></a>00099                 &lt;&lt; <span class="stringliteral">&quot;\n | TUNA::GeneralMesh : Can&#39;t open file \&quot; &quot;</span> &lt;&lt; filename &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>
<a name="l00100"></a>00100                 &lt;&lt; <span class="stringliteral">&quot;\n +-----+&quot;</span>;   
<a name="l00101"></a>00101     <span class="keywordflow">if</span>( <a class="code" href="classTuna_1_1GeneralMesh.html#adb1220f6fe8395185eba4973fa2e71e2" title="Dimension of the mesh.">Dim</a> == 1 ) 
<a name="l00102"></a>00102       <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0].size(); ++i)
<a name="l00103"></a>00103         file &lt;&lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0][i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; 0 &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00104"></a>00104     <span class="keywordflow">if</span> ( <a class="code" href="classTuna_1_1GeneralMesh.html#adb1220f6fe8395185eba4973fa2e71e2" title="Dimension of the mesh.">Dim</a> == 2 ) 
<a name="l00105"></a>00105       <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j &lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[1].size(); ++j) {
<a name="l00106"></a>00106         <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0].size(); ++i)
<a name="l00107"></a>00107           file &lt;&lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0][i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[1][j] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; 0 &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00108"></a>00108         file &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00109"></a>00109       }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111     <span class="keywordflow">if</span> (<a class="code" href="classTuna_1_1GeneralMesh.html#adb1220f6fe8395185eba4973fa2e71e2" title="Dimension of the mesh.">Dim</a> == 3 ) 
<a name="l00112"></a>00112       <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> k = 0; k &lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[2].size(); ++k) {
<a name="l00113"></a>00113         <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j = 0; j &lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[1].size(); ++j) {
<a name="l00114"></a>00114           <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0].size(); ++i)
<a name="l00115"></a>00115             file &lt;&lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[0][i] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[1][j] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[2][k] &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; 0 &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00116"></a>00116           file &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00117"></a>00117         }
<a name="l00118"></a>00118         file &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00119"></a>00119       }
<a name="l00120"></a>00120   }
<a name="l00121"></a>00121 
<a name="l00122"></a>00122 <span class="keyword">protected</span>:
<a name="l00123"></a><a class="code" href="classTuna_1_1GeneralMesh.html#adb1220f6fe8395185eba4973fa2e71e2">00123</a>   <span class="keywordtype">int</span> <a class="code" href="classTuna_1_1GeneralMesh.html#adb1220f6fe8395185eba4973fa2e71e2" title="Dimension of the mesh.">Dim</a>;               
<a name="l00124"></a><a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26">00124</a>   vector&lt;prec_t&gt; <a class="code" href="classTuna_1_1GeneralMesh.html#a8e75bc5cbf29abdbceb95226f1315c26" title="Coordinate arrays.">xyz</a>[3]; 
<a name="l00125"></a>00125   <span class="comment">//  ScalarField1D xyz_coord[3];</span>
<a name="l00126"></a>00126   <span class="keyword">typename</span> vector&lt;prec_t&gt;::const_iterator viter;
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 <span class="keyword">private</span>:
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 };
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 } <span class="comment">// Tuna namespace </span>
<a name="l00133"></a>00133 
<a name="l00134"></a>00134 
<a name="l00135"></a>00135 <span class="preprocessor">#endif //_GENERALMESH_H_</span>
<a name="l00136"></a>00136 <span class="preprocessor"></span>
<a name="l00137"></a>00137 
<a name="l00138"></a>00138 
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr size="1">
<div align="center">
Last modification: Sun Aug 28 09:57:21 CDT 2011
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&copy; 2011 LMCS-UNAM
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Generated by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="top" border="0" height="25"></a> 1.6.1 </div>

